package util;

import entity.Order;

import java.sql.ResultSet;
import java.sql.SQLException;

public class OrderUtil {
    private OrderUtil() {
    }

    // 从ResultSet中获取数据构建Order对象
    public static Order rsToOrder(ResultSet rs) throws SQLException {
        Order order = new Order();
        order.setOrderId(rs.getString("order_id"));
        order.setUserId(rs.getInt("user_id"));
        order.setAddId(rs.getInt("add_id"));
        order.setPayment(rs.getDouble("payment"));
        order.setPaymentType(rs.getInt("payment_type"));
        order.setPostFee(rs.getDouble("post_fee"));
        order.setStatus(rs.getInt("status"));
        order.setBuyerNick(rs.getString("buyer_nick"));
        order.setBuyerRate(rs.getInt("buyer_rate"));
        order.setUpdateTime(rs.getTimestamp("update_time"));
        order.setCreateTime(rs.getTimestamp("create_time"));
        order.setPaymentTime(rs.getTimestamp("payment_time"));
        order.setConsignTime(rs.getTimestamp("consign_time"));
        order.setEndTime(rs.getTimestamp("end_time"));
        order.setCloseTime(rs.getTimestamp("close_time"));
        order.setShippingName(rs.getString("shipping_name"));
        order.setShippingCode(rs.getString("shipping_code"));
        order.setBuyerMessage(rs.getString("buyer_message"));
        return order;
    }
}
